﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using EzDesk.MVVMBase;
using EzDesk.DesktopClient.ViewContract;
using EzDesk.Client.Utility;
using System.Windows;
using EzDesk.Generic.WPF;
using EzDesk.DesktopClient.Event;
using EzDesk.DesktopClient.MVVMEnhance;
using EzDesk.DesktopClient.ServiceLocator.ClientService;

namespace EzDesk.DesktopClient.ViewModel
{
    public class AppTaskViewModel : ViewModelWithSingleContainer<IAppTaskView>
    {
        private AppManagement _appManagement;
        private ObservableCollection<AppItemViewModel> _appItemViewModelCollection;
        public ObservableCollection<AppItemViewModel> AppItemViewModelCollection
        {
            get
            {
                if (_appItemViewModelCollection == null)
                {
                    this._appItemViewModelCollection = new ObservableCollection<AppItemViewModel>(_appManagement.AppCollection.Select(app => new AppItemViewModel(app)));
                }
                return _appItemViewModelCollection;
            }
            set
            {
                _appItemViewModelCollection = value;
            }
        }

        public AppTaskViewModel()
            : base()
        {
            Init();
        }

        private void Init()
        {
            InitManagement();
        }

        private void InitManagement()
        {
            _appManagement = this.Container.Resolve<AppManagement>();
        }
    }
}
